package personal.lzw._23java1studentdemo.controller;


import jakarta.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller           //定义一个控制器 相当于Servlet

@RequestMapping("/Student")  //请求映射，定义servlet的访问形式

public class StudentController {

    @RequestMapping("list")
    @ResponseBody      //响应给用户的是body
    public String list(){
        System.out.println("list");  //在控制台打印字符串list
        return "<h1>23java1</h1>";               //用户返回/templates/list.html页面
    }
    //增加学生
    @RequestMapping("addStudent")
    @ResponseBody
    public String addStudent(){
        System.out.println("addStudent");  //在控制台打印字符串addStudent
        return "addStudent";
    }
    //删除学生
    //登录
    //转到任意页面的方法，将目标页面名称当做参数传递
    @RequestMapping("toPage")
    public String toPage(String page){
        return page;

    }
    @RequestMapping("loginValidate")
        public String loginValidate(String username, String password, HttpServletRequest request){
        System.out.println(username+" , "+password+",from"+request.getRemoteAddr());
        return "list";
        }

}
